﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Xml;
using System.Windows.Resources;
using System.Collections.Generic;
using System.IO;
using lutianqi.Model;
using System.Xml.Linq;

namespace lutianqi.Helpers
{
    //读取城市名与城市编码映射关系
    public static class CityCodeMappingProcessor
    {
        public static List<CityCodeMapping> GetCityCodeMappingList()
        {
            List<CityCodeMapping> CityCodeMappingList = new List<CityCodeMapping>();
            XElement ele = XElement.Load("CityCode.xml");
            foreach (var item in ele.Descendants("Region").Descendants("City"))
            {
                CityCodeMappingList.Add(new CityCodeMapping { 
                    Region = item.Parent.Attribute("RegionName").Value, 
                    CityName = item.Attribute("Name").Value,
                    CityCode = item.Value
                });
            }
            return CityCodeMappingList;
        }
    }
}
